package com.study.lxy.springcloud.cardman.controller;

import com.study.lxy.springcloud.cardman.service.GenCardNoService;
import com.study.lxy.springcloud.common.format.ServiceResp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class CardCreateController {
    @Autowired
    private GenCardNoService genCardNoService;
    @PostMapping("generateCardNo")
    /**
     * 卡类型，业务类型对应的卡BIN，先在本地缓存查询，如查询不到，查询数据库加载到缓存
     * 此处当前序号使用redis存储，不再使用数据库生成序列号
     */
    public ServiceResp generateCardNo(@RequestParam String cardType, @RequestParam String busiType){
        String cardNo = genCardNoService.generateCardNo(cardType,busiType);
        return ServiceResp.buildResult(cardNo);
    }

}
